<template>
  <div class="mod-config">
    <h2 style="text-align: center;">添加球队信息</h2>

    <el-steps :active="2" process-status="wait" align-center style="margin-bottom: 40px;">
      <el-step title="球队资料"/>
      <el-step title="球队常规赛基础数据"/>
      <el-step title="球队常规赛进阶数据"/>
    </el-steps>

    <el-form  :model="list" label-width="100px"
    width="100" :inline="true" class="demo-form-inline" style="margin-left:10%">
  <el-form-item label="胜场数" >
    <el-input v-model="list.win" ></el-input>
  </el-form-item>
  <el-form-item label="败场数">
    <el-input v-model="list.fail"></el-input>
  </el-form-item>
  <el-form-item label="场均得分">
    <el-input v-model="list.score"></el-input>
  </el-form-item>
   <el-form-item label="场均失分">
    <el-input v-model="list.loseScore"></el-input>
  </el-form-item>
  <el-form-item label="场均篮板">
    <el-input v-model="list.rebounds"></el-input>
  </el-form-item>
  <el-form-item label="场均助攻">
    <el-input v-model="list.assists"></el-input>
  </el-form-item>
  <el-form-item label="场均抢断">
     <el-input v-model="list.steals"></el-input>
  </el-form-item>
   <el-form-item label="场均盖帽">
    <el-input v-model="list.block"></el-input>
  </el-form-item>
   <el-form-item label="投篮命中率">
    <el-input v-model="list.shootPercentage"></el-input>
  </el-form-item>
   <el-form-item label="三分命中率">
    <el-input v-model="list.threePercentage"></el-input>
  </el-form-item>
   <el-form-item label="罚球命中率">
    <el-input v-model="list.freePercentage"></el-input>
  </el-form-item>
   <el-form-item label="场均失误">
    <el-input v-model="list.fault"></el-input>
  </el-form-item>
  <el-form-item label="场均犯规">
    <el-input v-model="list.foul"></el-input>
  </el-form-item>
   <el-form-item label="正负值">
    <el-input v-model="list.pna"></el-input>
  </el-form-item>
   <el-form-item label="替补得分">
    <el-input v-model="list.alternate"></el-input>
  </el-form-item>
     <el-form-item label="赛季">
    <el-input v-model="list.season"></el-input>
  </el-form-item>
   <el-form-item label="赛程">
    <el-input v-model="list.stage"></el-input>
  </el-form-item>
    <br>
  <el-form-item class="b" style="margin-left:30%">
            <el-button @click="previous">上一步</el-button>
            <el-button type="primary" @click="saveOrUpdate">保存并下一步</el-button>
        </el-form-item>
</el-form>
 </div>
</template>
<script>
export default {
    data() {
      return {
          list:{
          id:'',
          teamId: '',
          win: '',
          fail: '',
          score: '',
          loseScore: '',
          rebounds: '',
          assists: '',
          steals: '',
          block: '',
          shootPercentage: '',
          threePercentage: '',
          freePercentage: '',
          fault: '',
          foul: '',
          pna: '',
          alternate: '',
          season: '',
          stage: ''
          }
      }
    },
    created(){
        if(this.$route.params && this.$route.params.id) {
           this.list.teamId=this.$route.params.id
           this.getbasicdateById()
        }
    },

     watch:{
          '$route'(to,from){
           if(this.$route.params && this.$route.params.id) {
           this.list.teamId=this.$route.params.id
           this.getbasicdateById()
            }
            }
        },
    methods: {
        addbasicdate(){
          this.$http({
          url: this.$http.adornUrl('/team/teambasicdate/save'),
          method: 'post',
          data:this.list
        }).then(({data}) => {
               this.$message({
                    type:'success',
                    message:'添加球队基本数据成功！'
                });
               this.$router.push({
                 path:'/team/team-add-advanced/'+this.$route.params.id
               });
        })
        },
          updatebasicdate(){
          this.$http({
          url: this.$http.adornUrl('/team/teambasicdate/update'),
          method: 'post',
          data:this.list
        }).then(({data}) => {
               this.$message({
                    type:'success',
                    message:'修改球队基本数据成功！'
                });
               this.$router.push({
                 path:'/team/team-add-advanced/'+this.$route.params.id
               });
        })
        },
          saveOrUpdate(){
            if(this.list.id == ''){
                this.addbasicdate()
            }else{
                this.updatebasicdate()
            }
         
        },
        previous() {
            this.$router.push({
                 path:'/team/team-add-information/'+this.$route.params.id
               });
        },
         getbasicdateById(){
          this.$http({
          url: this.$http.adornUrl(`/team/teambasicdate/infoByTeamId/${this.$route.params.id}`),
          method: 'post'
        }).then(({data}) => {
          if(data.teamBasicdate!=null){
              this.list = data.teamBasicdate
              console.log(this.list)
              }
             
        })
    }
    }
  }
</script>
<style>

</style>